#!/usr/local/bin/lua
--
--	Chapter 02	-	String
--
--	Michael Ge
--	2014.05.15
--

print("====================")

a = "one string"
b = string.gsub(a, "one", "another")

print(a)
print(b)

print("====================")

print("one line\nnext line\n\"in quotes\", 'in quotes'")
print('a backslash inside quotes: \'\\\'')

print("a simple way: '\\'")

print("====================")

function write(content)
	print(content)
end

page = [[
<html>
<head>
<title>An HTML Page</title>
</head>
<body>
<a href="http://www.lua.org">Lua</a>
</body>
</html>
]]

write(page)

print("====================")

print("10" + 1)
print("10 + 1")
print("-5.3e-10" * "2")
--print("hello" + 1)		-- ERROR

print("====================")

print(10 .. 20)

print("====================")

line = io.read()
n = tonumber(line)

if n == nil then
	error(line .. " is not a valid number")
else
	print(n * 2)
end

print("====================")

print(tostring(10) == "10")
print(10 .. "" == "10")

print("====================")

a = "hello"
print(#a)
print(#"good\0bye")

print("====================")